import React, { Suspense } from 'react'
import { ConfigProvider, Spin } from 'antd'
import zhCN from 'antd/locale/zh_CN'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import 'antd/dist/reset.css'
import { Outlet } from 'react-router-dom'
import { useThemeStore } from './stores'
import { theme } from 'antd'
import useWindowInit from './hooks/useInitWindow'

const App: React.FC = () => {
  dayjs.locale('zh-cn')
  const { isDark } = useThemeStore()
  const { defaultAlgorithm, darkAlgorithm } = theme
  useWindowInit()

  return (
    <ConfigProvider locale={zhCN} theme={{ algorithm: isDark ? darkAlgorithm : defaultAlgorithm }}>
      <Suspense fallback={<Spin size="large" className="globa_spin" />}>
        <Outlet />
      </Suspense>
    </ConfigProvider>
  )
}
export default App
